import config from "@/config"
import http from "@/utils/request"


export default {
  getMenus: {
    url: `${config.API_URL}/menu/list`,
    name: "获取菜单管理-菜单列表",
    get: function () {
      return new Promise((resolve, reject) => {
        http.get(this.url).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  addMenu: {
    url: `${config.API_URL}/menu/add`,
    name: "获取菜单管理-菜单列表",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  updateMenu: {
    url: `${config.API_URL}/menu/update`,
    name: "获取菜单管理-菜单修改",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  deleteMenu: {
    url: `${config.API_URL}/menu/delete`,
    name: "获取菜单管理-删除菜单",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  },
  deleteBatchMenu: {
    url: `${config.API_URL}/menu/deleteBatch`,
    name: "获取菜单管理-批量删除菜单",
    post: function (data) {
      return new Promise((resolve, reject) => {
        http.post(this.url, data).then((response) => {
          resolve(response)
        }).catch((error) => {
          resolve(error.data)
        })
      })
    }
  }
}
